
function options = check_parsed_input(argoutc, ...
                                      single,...
                                      multi,...
                                      popsize,...
                                      dimensions,...
                                      which_ones,...
                                      options)

    assert(all( 5*numel(which_ones) <= popsize ),...
           [mfilename ':popsize_too_small'], [...
           'Each algorithm requires a population size of at least 5.\n',...
           'Given value for [popsize] makes this impossible. Increase\n',...
           'option [popsize] to at least %d.'],...
           5*numel(which_ones));

    if numel(popsize) > 1
        assert(numel(popsize) == dimensions,...
               [mfilename ':popsize_invalid_dimensions'], [...
               'When specifying [popsize] as an array, the dimensions of that ',...
               'array should correspond to the number of algorithms used.']);

    end

    if (options.GODLIKE.ItersLb > options.GODLIKE.ItersUb)
        warning([mfilename ':ItersLb_exceeds_ItersUb'], [...
                'Value of options.GODLIKE.ItersLb is larger than value of\n',...
                'options.GODLIKE.ItersUb. Values will simply be swapped.']);
        u_b = options.GODLIKE.ItersUb;
        options.GODLIKE.ItersUb = options.GODLIKE.ItersLb;
        options.GODLIKE.ItersLb = u_b;
    end

    if (options.MinIters  > options.MaxIters)
        warning([mfilename ':MaxIters_exceeds_MinIters'], [...
                'Value of options.MinIters is larger than value of\n',...
                'options.MaxIters. Values will simply be swapped.']);
        u_b = options.MaxIters;
        options.MaxIters = options.MinIters;
        options.MinIters = u_b;
    end

    if single
        % single objective optimization has a maximum of 4 output arguments
        if verLessThan('MATLAB', '8.6')
            error(nargoutchk(0, 4, argoutc, 'struct')); %#ok<NCHKE>
        else
            nargoutchk(0, 4);
        end
    elseif multi
        % multi-objective optimization has a maximum of 6 output arguments
        if verLessThan('MATLAB', '8.6')
            error(nargoutchk(0, 6, argoutc, 'struct')); %#ok<NCHKE>
        else
            nargoutchk(0, 6);
        end
    end

    if ~isempty(options.OutputFcn) && ...
       ~all( cellfun(@(x) isa(x, 'function_handle'), options.OutputFcn))
        error([mfilename ':outputFcn_shouldbe_function_handle'],...
              'All output functions should be function handles.')
    end

    if strcmpi(options.display, 'plot') && single && dimensions > 2
        warning([mfilename ':plotting_not_possible'], [...
                'Display type was set to ''Plot'', but the number of\n',...
                'decision variables exceeds 2. The search space can note be\n',...
                'displayed. Set options.display to ''off'' or ''on'' to \n',...
                '''on'' to supress this message.'])
    end

    if strcmpi(options.display, 'plot') && multi && options.num_objectives > 3
        warning([mfilename ':plotting_not_possible'], [...
                'Display type was set to ''Plot'', but the number of\n',...
                'objective functions exceeds 3. The Pareto front can \n',...
                'not be displayed. Set options.display to ''off'' or \n',...
                '''on'' to supress this message.'])
    end
    
end 
